﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Zwms.Client.Helper;
using Zwms.Data.BusinessObjects;
using Zwms.Client;

namespace Zwms.Client.ManageWms
{
    public partial class StockQueryUC : UserControl
    {
        private StoGoodsStock _queryRecord;
        public StoGoodsStock QueryRecord { get { return _queryRecord;}}

        public StockQueryUC()
        {
            InitializeComponent();
            this._queryRecord = new StoGoodsStock();
            //if (MainForm.CurrentUser.UserRole != "01")
            //{
            //    this.tbsWarehouse.Tag = MainForm.CurrentUser.WarehouseCode;
            //    this.tbsWarehouse.SetTextBoxContent(MainForm.CurrentUser.WarehouseName);
            //    this.tbsWarehouse.SetEditState(false);
            //}

            //if (MainForm.CurrentUser.UserRole != "01")
            //{
            //    this.tbsWarehouse.Tag = MainForm.CurrentUser.WarehouseCode;
            //    this.tbsWarehouse.SetTextBoxContent(MainForm.CurrentUser.WarehouseName);
            //    this.tbsWarehouse.SetEditState(false);
            //}
        }

        public void EnableWarehouseUC(bool b,string strCode,string strName)
        {
            this.tbsWarehouse.Tag = strCode;
            this.tbsWarehouse.SetTextBoxContent(strName);
            this.tbsWarehouse.SetEditState(b);
        }

        public void SetQueryRecord()
        {
            
            if (this.tbsWarehouse.Tag != null)
            {
                this._queryRecord.WarehouseCode = this.tbsWarehouse.Tag.ToString();
            }
            this._queryRecord.IBPlanCode = this.tbInPlanCode.Text.Trim();
            this._queryRecord.GoodsCode = this.tbGoodsCode.Text.Trim();
            this._queryRecord.GoodsName = this.tbGoodsName.Text.Trim();
        }

        private void tbsWarehouse_SelectButtonClick(object sender, EventArgs e)
        {
            InfoWms.WarehouseWnd uc = new InfoWms.WarehouseWnd();
            CommonUI.ContainerForm window = new CommonUI.ContainerForm(uc, "选择仓库");
            uc.SetQueryState();
            if (window.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                tbsWarehouse.SetTextBoxContent(uc.SelectedRecord.WarehouseName);
                tbsWarehouse.Tag = uc.SelectedRecord.Id;
            }
        }
    }
}
